﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule.ExecuteWorkflowView"
    xmlns:Controls="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner;assembly=Microsoft.Research.ScientificWorkflow.UIDesigner"
    xmlns:Toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
    Width="950" Height="600" BorderBrush="#FF717171" BorderThickness="2" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <UserControl.Resources>
        <DataTemplate x:Key="ComboboxTemplate">
            <TextBlock Text="{Binding Path=Name}"/>
        </DataTemplate>
        <Controls:DeleteEnabledConverter x:Key="deleteEnabledConverter"></Controls:DeleteEnabledConverter>
    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="28"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="35"/>
        </Grid.RowDefinitions>
        <Border Name="brdrHeader" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Grid.Row="0" CornerRadius="4,4,0,0" Margin="0,0,0,0">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFF7F7F7" Offset="0"/>
                    <GradientStop Color="#FFE9E9E9" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid>
                <TextBlock HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Center" FontSize="14" Foreground="#FF5F5F5F" Text="{Binding Path=WorkflowName}" TextWrapping="Wrap"/>
                <Button HorizontalAlignment="Right" Margin="0,5.5,5,5.5" Style="{DynamicResource PopupCloseButton}" Width="17" Command="{Binding Path=CloseWindowCommand}" AutomationProperties.AutomationId="ExecuteWindowCloseButton" />
            </Grid>

        </Border>
        <!--<Border Padding="2" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="#FFD0D0D0"  BorderThickness="2,0,2,2">-->
        <Grid Grid.Row="1" Grid.RowSpan="1" Background="#FFFFFFFF">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.6*" />
                <ColumnDefinition Width="0.4*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="220" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Border Margin="10,10,10,10" BorderBrush="#FFD0D0D0" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Grid.ColumnSpan="2">
                <Border x:Name="composerHost" BorderBrush="#FFD0D0D0" BorderThickness="0,0,0,0" CornerRadius="5,5,5,5"/>
            </Border>
            <Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Grid.Row="1" Grid.Column="1" Margin="10,0,10,10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
                        <Border.Background>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                <GradientStop Color="#FFE8E8E8" Offset="1"/>
                            </LinearGradientBrush>
                        </Border.Background>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="28"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Workflow Required Parameters" TextWrapping="Wrap" Margin="5,0,0,0" FontSize="13"/>
        				</Grid>
                    </Border>
                    <Border Grid.RowSpan="1" Grid.Row="1" Margin="5,5,5,5" x:Name="PropertyPaneHost">

                    </Border>
                </Grid>
            </Border>
            <Grid Grid.Row="1" Background="#FFFFFFFF">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" MinHeight="134.332"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" HorizontalAlignment="Stretch" d:LayoutOverrides="Height" Margin="10,0,0,10">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="25"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFE8E8E8" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Details" TextWrapping="Wrap" Margin="5,0,0,0" FontSize="13"/>
        					</Grid>
                        </Border>
                        <Grid HorizontalAlignment="Stretch" Margin="5,2,5,5" Grid.Row="1" Grid.RowSpan="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto" MinHeight="0"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="80"/>
                                <ColumnDefinition Width="190"/>
                                <ColumnDefinition Width="65"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Job Name:" TextWrapping="Wrap" Grid.ColumnSpan="1" Grid.RowSpan="1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,5,0"/>
        					<TextBlock Text="Node:" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Row="1" Margin="0,5,5,0"/>
        					<ComboBox SelectedItem="{Binding Path=SelectedMachine}" ItemsSource="{Binding Path=NodeList}" ItemTemplate="{StaticResource ComboboxTemplate}" IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,5,0,0" Width="175" Grid.Column="1" Grid.Row="1" AutomationProperties.AutomationId="SelectMachineComboBox" DropDownOpened="OnMachineListDropDownOpened"/>
        					<TextBox Text="{Binding Path=JobName}" MaxLength="75" MaxLines="1"  VerticalAlignment="Center" Grid.Column="1" HorizontalAlignment="Left" Width="175" AutomationProperties.AutomationId="JobNameTextBox" TextWrapping="NoWrap"/>
                            <TextBlock Text="Run By:" TextWrapping="Wrap" HorizontalAlignment="Right" d:LayoutOverrides="Height" Grid.Row="2" VerticalAlignment="Top" Margin="0,5,5,0"/>
        					<ComboBox Grid.Row="2" Grid.Column="1" SelectedItem="{Binding Path=SelectedUser}" ItemsSource="{Binding Path=UserList}"  ItemTemplate="{StaticResource ComboboxTemplate}" IsSynchronizedWithCurrentItem="True" d:LayoutOverrides="Height"  HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,5,0,0" Width="175" AutomationProperties.AutomationId="UsersComboBox"/>
        					<TextBox Text="{Binding Path=JobNotes}" MaxLines="4" MaxLength="300" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Stretch" Width="175" Grid.Column="3" Grid.RowSpan="3" AutomationProperties.AutomationId="jobNotes" VerticalScrollBarVisibility="Auto" />
        					<TextBlock Text="Notes:" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Right" Margin="0,5,5,0" VerticalAlignment="Top" Grid.Column="2"/>
        					<CheckBox IsChecked="{Binding Path=ShowMonitor}" Content="Show Monitor Window" VerticalAlignment="Top" d:LayoutOverrides="Width" HorizontalAlignment="Left" Margin="0,5,0,0" Grid.Column="3" Grid.Row="3" AutomationProperties.AutomationId="ShowMonitorCheckBox"/>
        				</Grid>
                    </Grid>
                </Border>
                <Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" d:LayoutOverrides="Height" Grid.Row="1" Margin="10,0,0,10">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="25"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFE8E8E8" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Additional Parameters" TextWrapping="Wrap" Margin="5,0,0,0" FontSize="13"/>
        					</Grid>
                        </Border>
                        <Grid Grid.Row="1" Grid.RowSpan="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="30"/>
                            </Grid.RowDefinitions>
                            <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" CornerRadius="0,0,5,5" Grid.Row="1" BorderThickness="0,1,0,0" BorderBrush="#FFE4E4E4">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                        <GradientStop Color="#FFEAEAEA" Offset="0.991"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,0">
                                    <Button Content="Delete" Width="60" Margin="0,0,5,0" Command="{Binding Path=DeleteAdditionalParameterCommand}" CommandParameter="{Binding ElementName=dataGrid, Path=SelectedItem}">
                                        <Button.IsEnabled>
                                            <MultiBinding Converter="{StaticResource deleteEnabledConverter}">
                                                <Binding ElementName="dataGrid" Path="HasItems"></Binding>
                                                <Binding ElementName="dataGrid" Path="SelectedItem"></Binding>
                                            </MultiBinding>
                                        </Button.IsEnabled>
                                    </Button>
                                    <Button Content="Add" Width="60" Command="{Binding Path=AddAdditionalParameterCommand}"/>
                                </StackPanel>
                            </Border>
                            <Toolkit:DataGrid Margin="5,5,2,5" Grid.RowSpan="1" x:Name="dataGrid" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserDeleteRows="False"  CanUserAddRows="False" CanUserSortColumns="False" CanUserReorderColumns="False" AutoGenerateColumns="False" ItemsSource="{Binding Path=AdditionalParameters}" HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" SelectionMode="Single">
                                <Toolkit:DataGrid.Columns>
                                    <Toolkit:DataGridTextColumn Width="170" Binding="{Binding Path=Domain}" Header="Domain"></Toolkit:DataGridTextColumn>
                                    <Toolkit:DataGridTextColumn Width="173" Binding="{Binding Path=Parameter}" Header="Parameter Name"></Toolkit:DataGridTextColumn>
                                    <Toolkit:DataGridTextColumn Width="180" Binding="{Binding Path=ParameterValue}" Header="Parameter Value"></Toolkit:DataGridTextColumn>
                                </Toolkit:DataGrid.Columns>
                            </Toolkit:DataGrid>
                        </Grid>
                    </Grid>
                </Border>
            </Grid>
        </Grid>
        <Border CornerRadius="0,0,5,5" BorderThickness="1,1,1,1" BorderBrush="#FFE4E4E4" VerticalAlignment="Stretch" Grid.Row="2">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFF0F0F0" Offset="0"/>
                    <GradientStop Color="#FFD2D2D2" Offset="0.991"/>
                </LinearGradientBrush>
            </Border.Background>
            <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
                <Button IsDefault="True" Content="Execute" Width="70" Margin="0,0,5,0" Command="{Binding Path=CreateJobCommand}" AutomationProperties.AutomationId="ExecuteJobButton"/>
                <Button IsCancel="True" Content="Cancel" Width="70" Command="{Binding Path=CloseWindowCommand}" AutomationProperties.AutomationId="CancelButton"/>
            </StackPanel>
        </Border>
        <!--</Border>-->
    </Grid>
</UserControl>
